package so.wy.servicecenter.businessbed.dao.enums;

/**
 * @author NO
 * @version 0.1.0
 * @since 2019.01.21
 */
public enum StatusDeviceRunEnum {
    /**
     * 可租赁
     */
    RENTABLE(1, "可租赁"),
    /**
     * 可归还
     */
    RETURNABLE(2, "可归还"),
    /**
     * 故障中
     */
    ERROR(3, "故障中");

    private Integer code;
    private String name;

    StatusDeviceRunEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static StatusDeviceRunEnum codeOf(Integer code) {
        if (code == null) {
            return null;
        }

        StatusDeviceRunEnum[] values = values();
        for (StatusDeviceRunEnum value : values) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    public static String codeOfDesc(Integer code) {
        StatusDeviceRunEnum value = codeOf(code);

        return value == null ? "" : value.getName();
    }
}